#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
|===== Conference Bot Plugin ============
|= Plugin Template
|===== By: ==============================
|= Patrick Kennedy
|===== Current Version: =================
|= 1.0
|===== Description: =========================================
|= A basic template for how to design commands.
|===== Additional Comments: =================================
|= 
|============================================================"""

#Any imports the plugin needs.
import re


def cmd_template(bot,user,args):
	"""A short description here.
	Usage: command <required> [optional]
	<required> - Any required arguments should be enclosed in <>s
	[optional] - Any optional arguments should be englosed in []s
	Note: Leaving this section out will cause the command to not be listed in )help."""
	
	#Add whatever you want the command do to here.
	if args:
		bot.msg(user, "Thank you for sending me: \n%s" % args)
		return
	#Returns the full doc string if the user didn't submit any args.
	#This is also the help for the command.
	bot.msg(user, cmd_template.__doc__)
	

def cmd_example(bot,user,args):
	"""Repeat a message.
	Usage: example "<message>" [bold | italics | both]
	<message> - A message enclosed in quotations.
	[style] - Message styles"""
	  
	try:
		message,args = re.findall("\"(.*)\" (.*)",args)[0]
	except:
		bot.msg(user, cmd_template.__doc__)
		
	message = sub_styles(message, args)
		
	bot.msg(user, message)

#Sub commands are internal commands that just keep things looking nicer.
def sub_styles(message, args):
	"""No doc string is required, but it's still useful."""
	if args in ["bold", "both", "all"]:
		message = "*"+ message +"*"
		
	if args in ["italics", "both", "all"]:
		message = "_"+ message +"_"
	
	return message
	
def init(bot):
	#Add the command so it can be used by that group.
	#The first arg is what must come after the ) to be recognized.
	bot.addAdminCommand("example",cmd_example)
